const paramStr = location.search
// console.log(paramStr)
const params = new URLSearchParams(paramStr)
params.forEach(async (value, key) => {
	// console.log(value, key)
	if (key === 'id') {
		const res = await axios({
			url: `cdBrand/getBrandDetail/${value}`
		})
		console.log(res.data.result)
		const date=res.data.result
		
		//设置title和meta
		document.querySelector('title').innerHTML=date.btitle?date.btitle:date.bname+'- 柴垛'
		document.querySelector('[name="keywords"]').content=date.bkeyword?date.bkeyword+ ',柴垛' :date.bname+',' + '柴垛,柴垛' +date.bname+',' + '柴垛,柴垛' +date.bname+',' + '柴垛,柴垛'
		document.querySelector('[name="description"]').content=date.bdesc?date.bdesc : '柴垛（www.chaiduo.com）汇聚' + date.bname + '优质知识内容及' + date.bname + '相关的资讯内容'
		document.querySelector('[itemprop="name"]').content=date.btitle ? '柴垛_' + date.btitle : '柴垛_' + date.bname
		document.querySelector('[itemprop="description"]').content=date.bdesc ? date.bdesc : '柴垛（www.chaiduo.com）汇聚' + date.bname + '优质知识内容及' + date.bname + '相关的资讯内容'
		document.querySelector('[itemprop="image"]').content=date.bcoverImg
		document.querySelector('[rel=canonical]').href=`https://www.chaiduo.com/p/` + date.id
		
		const str=`
		<img src="${date.bcoverImg}" alt="">
		<div class="categoryTitle">
			<span class="categoryName">${date.bname}</span>
			<a href='./brand.html'><span class="categoryLabel">品牌</span></a>
			<p class="categoryDes">${date.bslogan}</p>
			<div class="inf">
				<span>发布量：<span class="orange">${date.releaseNum}</span></span>&nbsp;&nbsp;&nbsp;&nbsp;
				<span>浏览量：<span class="orange">${date.viewNum}</span></span>
			</div>
		
		</div>`
		document.querySelector('.categoryPiece').innerHTML=str
		axios({
			url:'cdArticle/getActicleListByBrand',
			method:'post',
			data:{
				brandId: value,
				pageNo: 1,
				pageSize: 20
			}
		}).then(res=>{
			console.log(res.data.result.list)
			const list=res.data.result.list
			document.querySelector('.resContent ul').innerHTML=list.map(item=>{
				return `
				<a href='./article.html?aId=${item.id}'>
					<li>
						<h3>${item.title}</h3>
						<div class="center">
							<div class="img">
								<img src="${item.coverImg}" alt="">
							</div>
							<p>${item.descript}</p>
						</div>
						<div class="details">
							<span>${item.createTime}</span>
							<div class="point"></div>
							<span>${item.brands[0].bname}</span>
							<div class="point"></div>
							<span>${item.homeCategory}</span>
							<div class="point"></div>
							<span>${item.readNum}阅读</span>
						</div>
					</li>
				</a>`
			})
		})

	}
})

